const download = (res: object, fileName?: string) => {

    let  blob: Blob = res.data
    let contentDisposition = res.headers['content-disposition'];
    if (contentDisposition) {
        fileName = fileName ? fileName : window.decodeURI(contentDisposition.split('=')[1], "UTF-8");
    }
 
    // 创建 href 超链接，点击进行下载
    window.URL = window.URL || window.webkitURL
    const href = URL.createObjectURL(blob)
    const downA = document.createElement('a')
    downA.href = href
    console.log(fileName);
    downA.download = fileName
    downA.click()
    // 销毁超连接
    window.URL.revokeObjectURL(href)
}

export default download
